<style lang="scss">
	@import '/uni_modules/uview-ui/index.scss';
</style>

<script>
	const api = require('api.js');
	const message = require('message.js');
	const push = require('push.js');
	export default {
		onLaunch: function() {
			console.log('App Launch');
			try {
				api.init();
				message.init();
				push.init();
			} catch (e) {}
			try {
				api.onReceiveMsgCallback((msg) => {
					if (msg.type == 'exam_prestart') {
						if (message.isPushEnabled()) {
							push.createPushMessages("点击此处快速进入>>", {
								url: '/pages/exam/exam?examId=' + msg.options
							}, {
								title: '你有一场考试即将开始'
							}, true);
						}
					} else if (msg.type == 'new_message') {
						message.loadMessageList();
						if (message.isPushEnabled()) {
							push.createPushMessages("点击此处查看>>", {
								url: '/pages/message/message'
							}, {
								title: '你收到了一条系统消息'
							}, true);
						}
					}
				});
				api.connectWebSocket();
			} catch (err) {

			}
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
</style>
